<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Hello</title>
    <link rel="stylesheet" href="/static/css/font-awesome.css">
    <script src="/static/js/jquery-2.1.1.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        html, body {
            width: 100%;
            height: 100%;
            overflow: hidden;
            font-family: "Source Sans Pro",sans-serif;
        }
        .login_page {
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0) linear-gradient(to right bottom, #1abc9c 0%, #53e3a6 100%) repeat scroll 0 0;
        }
        .login_container {
            position: absolute;
            left: 50%;
            top: 50%;
            margin: -250px 0 0 -200px;
            z-index: 2;
        }
        .login_inline_block {
            display: inline-block;
        }
        .login_content {
            width: 400px;
            height: 335px;
            border: 1px solid #ebeff0;
            border-radius: 8px;
            background: #ebeff0;
        }
        .login_content form {
            width: 100%;
            height: 100%;
            padding-top: 50px;
            text-align: left;
        }
        .login_title {
            color: white;
            font-weight: bold;
            text-align: center;
            padding-bottom: 30px;
        }
        .login_title i {
            font-weight: bold;
            font-size: 30px;
            text-indent: -10px;
            padding-right: 30px;
        }
        .login_bubbles {
            width: 100%;
            height: 100%;
            position: relative;
            z-index: 1;
        }
        .login_content p {
            width: 80%;
            height: 40px;
            line-height: 40px;
            margin: 0 auto;
            margin-bottom: 20px;
            border: 1px solid #ffffff;
            background: #fff;
            border-radius: 6px;
            color: #929191;
        }
        .login_content p i {
            float: right;
            line-height: 40px;
            width: 30px;
            height: 100%;
        }
        .login_content p.login_button button {
            width: 100%;
            height: 40px;
            background: #1abc9c;
            border-radius: 5px;
            color: #fff;
            font-size: 14px;
            font-weight: bold;
            cursor: pointer;
        }
        .login_content input {
            float: left;
            height: 20px;
            padding: 10px;
            border: none;
            color: #929191;
        }
        .login_content p i.login_captcha {
            width: 130px;
            position: relative;
            top: 5px;
        }
        #login_tips {
            text-align: center;
            color:red;
        }
        .bg-bubbles {
            height: 100%;
            left: 0;
            position: absolute;
            top: 0;
            width: 100%;
            z-index: 1;
            list-style-type: none;
        }
        .bg-bubbles li {
            animation: 10s ease 0s normal none infinite running square;
            background-color: rgba(255, 255, 255, 0.15);
            bottom: -160px;
            display: block;
            height: 40px;
            list-style: outside none none;
            position: absolute;
            transition-timing-function: linear;
            width: 40px;
        }
        .bg-bubbles li:nth-child(1) {
            left: 10%;
        }
        .bg-bubbles li:nth-child(2) {
            animation-delay: 2s;
            animation-duration: 17s;
            height: 80px;
            left: 20%;
            width: 80px;
        }
        .bg-bubbles li:nth-child(3) {
            animation-delay: 4s;
            left: 25%;
        }
        .bg-bubbles li:nth-child(4) {
            animation-duration: 22s;
            background-color: rgba(255, 255, 255, 0.25);
            height: 60px;
            left: 40%;
            width: 60px;
        }
        .bg-bubbles li:nth-child(5) {
            left: 70%;
        }
        .bg-bubbles li:nth-child(6) {
            animation-delay: 3s;
            background-color: rgba(255, 255, 255, 0.2);
            height: 120px;
            left: 80%;
            width: 120px;
        }
        .bg-bubbles li:nth-child(7) {
            animation-delay: 7s;
            height: 160px;
            left: 32%;
            width: 160px;
        }
        .bg-bubbles li:nth-child(8) {
            animation-delay: 15s;
            animation-duration: 40s;
            height: 20px;
            left: 55%;
            width: 20px;
        }
        .bg-bubbles li:nth-child(9) {
            animation-delay: 2s;
            animation-duration: 40s;
            background-color: rgba(255, 255, 255, 0.3);
            height: 10px;
            left: 25%;
            width: 10px;
        }
        .bg-bubbles li:nth-child(10) {
            animation-delay: 11s;
            height: 160px;
            left: 90%;
            width: 160px;
        }
        @keyframes square {
            0% {
                transform: translateY(0px);
            }
            100% {
                transform: translateY(-700px) rotate(600deg);
            }
        }
    </style>
</head>
<body>
<div class="login_page">
    <div class="login_bubbles">
        <ul class="bg-bubbles">
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
    <div class="login_container">
        <div class="login_title">
            <i class="fa fa-american-sign-language-interpreting login_inline_block"></i>
            <h1 class="login_inline_block">后台登陆</h1>
        </div>
        <div class="login_content">
            <form>
                <p>
                    <input type="text" name="username" placeholder="用户名" value="admin"><i class="fa fa-user"></i>
                </p>
                <p>
                    <input type="password" name="password" placeholder="密码" value="123456"><i class="fa fa-key"></i>
                </p>
                <p>
                    <input type="text" name="captcha" placeholder="验证码" style="width:140px;"><i class="login_captcha">
                    <img src="{:captcha_src()}" alt="验证码" id="login_captcha_again"/></i>
                </p>
                <p class="login_button">
                    <button type="button" id="login_submit">登&nbsp;&nbsp;录</button>
                </p>
                <div id="login_tips"></div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
<script>
    $(function () {
        var login_info = (function () {
            var catpcha_again = $("#login_captcha_again");
            var again_src = catpcha_again.attr("src");
            var login_submit=$("#login_submit");
            var login_tips=$("#login_tips");
            return {
                ele_again: catpcha_again,
                again_src: again_src,
                login_submit:login_submit,
                login_tips:login_tips
            };
        })();
        //验证码
        login_info.ele_again.click(function () {
            set_captcha(this);
        });
        //点击登陆
        login_info.login_submit.click(function() {
            $.ajax({
                url: "{:url('login/login_on')}",
                type: "post",
                data: $("form").serialize(),
                success: function (data) {
                    if (data.status == "1") {
                        location.href = data.url;
                    } else {
                        login_info.ele_again.click();
                        login_info.login_tips.html($('<span class="fa fa-question-circle"> ' + data.msg + ' </span>'));
                    }
                }
            });

        });
        //ajax 回调
        function success(data){
            if(data.status == "1"){
                location.href=data.route;
            }else{
                login_info.login_tips.html($('<span class="fa fa-question-circle"> '+data.msg+' </span>'));
            }
        }
        //点击验证码
        function set_captcha(that)
        {
            $(that).attr("src", login_info.again_src + "?random=" + Math.random());
        }
    });


</script>
